package cc.owoo.godpen.analysis.html;

/**
 * Created by 摸鱼
 * 2022/05/23 上午 10:46
 */
public class NodeList extends HtmlList<Node> {
    /**
     * 序列化
     *
     * @return 序列化字符串
     */
    public String stringify() {
        StringBuilder string = new StringBuilder();
        for (Node node : this) {
            if (node instanceof Text text)
                string.append(text.text);
            else if (node instanceof Annotation annotation)
                string.append(annotation.text);
            else if (node instanceof Element element)
                element.stringify(string, true, true);
            string.append('\n');
        }
        return string.toString();
    }
}
